package logic

import (
	"context"
	"gitee.com/jmdvirus/jkgo/jk/jklog"

	"autotestservice/testservices/internal/svc"
	"autotestservice/testservices/internal/types"

	"github.com/tal-tech/go-zero/core/logx"
)

type AutotestLoginLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAutotestLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) AutotestLoginLogic {
	return AutotestLoginLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AutotestLoginLogic) AutotestLogin(req types.TestUser) (*types.Response, error) {
	jklog.L().Infoln("login with username ", req.UserName)

	res := &types.Response{
		Code:    400,
		Message: "no permission",
	}
	if req.Password == "qoiwekasfd" {
		res.Code = 0
		res.Message = "success"
	}

	return res, nil
}
